home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / net / route.h < prev   
C/C++ Source or Header  |  1988-10-23  |  3KB  |  93 lines

  1. /*
  2.  * Copyright (c) 1980, 1986 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that this notice is preserved and that due credit is given
  7.  * to the University of California at Berkeley. The name of the University
  8.  * may not be used to endorse or promote products derived from this
  9.  * software without specific prior written permission. This software
  10.  * is provided ``as is'' without express or implied warranty.
  11.  *
  12.  *    @(#)route.h    7.3 (Berkeley) 12/30/87
  13.  */
  14.  
  15. #ifndef _ROUTE
  16. #define _ROUTE
  17.  
  18. /*
  19.  * Kernel resident routing tables.
  20.  *
  21.  * The routing tables are initialized when interface addresses
  22.  * are set by making entries for all directly connected interfaces.
  23.  */
  24.  
  25. /*
  26.  * A route consists of a destination address and a reference
  27.  * to a routing entry.  These are often held by protocols
  28.  * in their control blocks, e.g. inpcb.
  29.  */
  30. struct route {
  31.     struct    rtentry *ro_rt;
  32.     struct    sockaddr ro_dst;
  33. };
  34.  
  35. /*
  36.  * We distinguish between routes to hosts and routes to networks,
  37.  * preferring the former if available.  For each route we infer
  38.  * the interface to use from the gateway address supplied when
  39.  * the route was entered.  Routes that forward packets through
  40.  * gateways are marked so that the output routines know to address the
  41.  * gateway rather than the ultimate destination.
  42.  */
  43. struct rtentry {
  44.     u_long    rt_hash;        /* to speed lookups */
  45.     struct    sockaddr rt_dst;    /* key */
  46.     struct    sockaddr rt_gateway;    /* value */
  47.     short    rt_flags;        /* up/down?, host/net */
  48.     short    rt_refcnt;        /* # held references */
  49.     u_long    rt_use;            /* raw # packets forwarded */
  50.     struct    ifnet *rt_ifp;        /* the answer: interface to use */
  51. };
  52.  
  53. #define    RTF_UP        0x1        /* route useable */
  54. #define    RTF_GATEWAY    0x2        /* destination is a gateway */
  55. #define    RTF_HOST    0x4        /* host entry (net otherwise) */
  56. #define    RTF_DYNAMIC    0x10        /* created dynamically (by redirect) */
  57. #define    RTF_MODIFIED    0x20        /* modified dynamically (by redirect) */
  58.  
  59. /*
  60.  * Routing statistics.
  61.  */
  62. struct    rtstat {
  63.     short    rts_badredirect;    /* bogus redirect calls */
  64.     short    rts_dynamic;        /* routes created by redirects */
  65.     short    rts_newgateway;        /* routes modified by redirects */
  66.     short    rts_unreach;        /* lookups which failed */
  67.     short    rts_wildcard;        /* lookups satisfied by a wildcard */
  68. };
  69.  
  70. #ifdef KERNEL
  71. #define    RTFREE(rt) \
  72.     if ((rt)->rt_refcnt == 1) \
  73.         rtfree(rt); \
  74.     else \
  75.         (rt)->rt_refcnt--;
  76.  
  77. #ifdef    GATEWAY
  78. #define    RTHASHSIZ    64
  79. #else
  80. #define    RTHASHSIZ    8
  81. #endif
  82. #if    (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
  83. #define RTHASHMOD(h)    ((h) & (RTHASHSIZ - 1))
  84. #else
  85. #define RTHASHMOD(h)    ((h) % RTHASHSIZ)
  86. #endif
  87. struct    mbuf *rthost[RTHASHSIZ];
  88. struct    mbuf *rtnet[RTHASHSIZ];
  89. struct    rtstat    rtstat;
  90. #endif
  91.  
  92. #endif /* _ROUTE */
  93.